/*
This example copies one view on the current drawing.
*/
#include <stdlib.h>
#include <stdio.h>
#include <uf.h>
#include <uf_defs.h>
#include <uf_draw.h>
#include <uf_obj.h>
#include <uf_part.h>
#include <uf_view.h>
void ufusr(char *param, int *retcod, int param_len)
{
  int         ifail = 0;
  tag_t       view_tag = NULL_TAG;
  tag_t       part_tag = NULL_TAG;
  tag_t       drawing_tag = NULL_TAG;
  tag_t       new_view_tag = NULL_TAG;
  char        view_name[31] = "TOP@1";
  char        error_message[133];
  double     dwg_reference_pt[2] = {150.0, 150.5};

  ifail = UF_initialize();

  if( !ifail )
      part_tag = UF_PART_ask_display_part();

  if( !ifail && part_tag != NULL_TAG )
      ifail = UF_DRAW_ask_current_drawing( &drawing_tag );

  if( !ifail && part_tag != NULL_TAG && drawing_tag != NULL_TAG )
      ifail = UF_VIEW_ask_tag_of_view_name( view_name,
                                           &view_tag );

  if( !ifail && part_tag != NULL_TAG &&
      drawing_tag != NULL_TAG && view_tag != NULL_TAG )
          ifail = UF_DRAW_copy_view( view_tag,&new_view_tag );

          UF_DRAW_move_view( new_view_tag,dwg_reference_pt );


  printf( "UF_DRAW_copy_views " );
  if( ifail )
  {
      ifail = UF_get_fail_message( ifail, error_message );
      printf( "fails. \nError is:%s\n", error_message );
  }
  else if( part_tag == NULL_TAG )
      printf( "fails.\nError is: no active part.\n" );
  else if ( drawing_tag == NULL_TAG )
      printf( "fails.\nError is: drawing not found.\n" );
  else
      printf( "is successful.\n" );

  ifail = UF_terminate();
}


